package com.bdqn.boot.yuanshen.service.impl;

import com.bdqn.boot.yuanshen.bean.Admin;
import com.bdqn.boot.yuanshen.mapper.AdminMapper;
import com.bdqn.boot.yuanshen.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * @author fly
 * @version 1.0
 * @className AdminServiceImpl
 * @description TODO
 * @date 2025/3/17 11:43
 */
@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin login(String username, String password) {
        Admin admin = adminMapper.login(username);
        if (admin == null) {
            throw new RuntimeException("用户名不存在");
        }
        if (!admin.getPassword().equals(password)){
            throw new RuntimeException("密码错误");
        }
        return admin;
    }

    @Override
    public int getVideosCount() {
        return adminMapper.getVideosCount();
    }

    @Override
    public int getUsersCount() {
        return adminMapper.getUsersCount();
    }

    @Override
    public int getUserBehavior() {
        return adminMapper.getUserBehavior();
    }
}
